<?php

require("../vendor/autoload.php");
Logger::configure("../config/log4php.xml");
$logger = Logger::getLogger("redis");

$redis = new \Redis();
$redis->connect('127.0.0.1', '6379');
$redis->select(0);
$redis_name = "miaosha";
$num = 50;//50人秒杀成功
$n = 0;
$pleNum = 0;
$logger->info( '秒杀开始' );

for ($pleNum;$pleNum<10;$pleNum++){
    $redis->lPush($redis_name,'***--'.$pleNum);
}
while ($redis->lLen($redis_name) > 0){
    $u_id = mt_rand(1000000, 9999999);
    $s = $redis->lPop($redis_name);
    echo $s . '秒杀成功---' . $u_id . "---\n";
    $logger->info($u_id . '秒杀成功' );
}


$logger->info( '已经结束' );


$redis->close();
echo "end";